// 节流的重点在于加锁
export function throttle(fn, wait) {
  let timer = null;
  let lock = false;
  return function (...args) {
    if (!lock) {
      lock = true;
      timer = setTimeout(() => {
        lock = false;
        timer = null;
        clearTimeout(timer);
        fn.call(this, ...args);
      }, wait);
    }
  };
}
